#ifndef COMPOSITION__TALKER_COMPONENT_HPP_
#define COMPOSITION__TALKER_COMPONENT_HPP_

#include "UsbCaptureSystem.h"
#include "rclcpp/rclcpp.hpp"
#include <cv_bridge/cv_bridge.hpp>
#include "sensor_msgs/msg/image.hpp"
#include "base_interfaces/srv/gimbal_pose.hpp"
#include <camera_info_manager/camera_info_manager.hpp>
#include <string>

using std::placeholders::_1;

namespace wmj
{
    class camera_node : public rclcpp::Node
    {
    public:
        explicit camera_node(const rclcpp::NodeOptions & options);

        //利用 GetImg 获取图像，传入类型为 sensor_msgs::msg::Image ，返回为 cv::Mat 类型
        static cv::Mat GetImg(sensor_msgs::msg::Image img);


    private:
        typedef rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr m_Imagepub;
        typedef rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr m_Camera; 
        typedef std::shared_ptr<camera_info_manager::CameraInfoManager> m_Cim;
        std::vector<m_Camera> Camera;
        std::vector<m_Cim> Cim;
        std::map<std::string,m_Imagepub> imageMapping;
        rclcpp::TimerBase::SharedPtr timer;                                     // 创建定时器
        int m_camera_num = 0;                                                   // 相机数量
        std::shared_ptr<wmj::UsbCaptureSystem> m_capture ;                      // 声明相机用于读图
        std::vector<wmj::MatWithTime> m_frames;                                 // 读取图像变量
        bool init = false;

        /***
         * @brief  Gimbalpose服务端回调函数
         * 
         * @param response GimbalPose信息
        */
        void GimbalPose_callback(rclcpp::Client<base_interfaces::srv::GimbalPose>::SharedFuture response);     
        
        /***
         * @brief 时间回调函数
        */
        void timer_callback();

        void RosImageCallBack(wmj::MatWithTime& raw_img,std::string orientation);

        /***
         * @brief 设置qos_t与qos
         * @param if_reliable 传输质量是否可靠
         * @param depth 传输深度
        */
        rclcpp::QoS setQos(bool if_reliable, int depth);
        rmw_qos_profile_t setQos_t(bool if_reliable, int depth);
    };
}

#endif
